String.prototype.split("")は書記素クラスタを破壊
するのか。/icons/知らんかった.icontakker.icon
例https://stackoverflow.com/questions/4547609/how-to-get-character-array-from-a-string/34717402#34717402
一列目がString.prototype.split()
見事にサロゲートペアが壊れている
2列目がspread operatorを使って配列にしたもの
書記素クラスタが壊れていない
3列目はfor...ofを使ったもの
2列目と同様
code:js
const text = "𝟘𝟙𝟚𝟛";
alert(
`${JSON.stringify(text.split(""))}
${JSON.stringify(...text)}
${(() => {
const stack = [];
for (const i of text) {
stack.push(i);
}
return JSON.stringify(stack);
})()}`
);
#2021-10-12 00:17:04